/*
 * @Author: xuwejie 1529315455@qq.com
 * @Date: 2023-08-28 17:16:04
 * @LastEditors: xuwejie 1529315455@qq.com
 * @LastEditTime: 2023-09-01 14:26:59
 * @FilePath: \cdj_crm-vue\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'
// import orderRouter from '@/router/modules/order'
import purchasingRouter from '@/router/modules/purchasing'
import warehouseRouter from '@/router/modules/warehouse'
import sortingRouter from '@/router/modules/sorting'
import commodityRouter from '@/router/modules/commodity'
import userRouter from '@/router/modules/user'
import marketingRouter from '@/router/modules/marketing'
import financialRouter from '@/router/modules/financial'
import kitchenRouter from '@/router/modules/kitchen'
import distributionRouter from '@/router/modules/distribution'
import globalRouter from '@/router/modules/global'
import documentRouter from '@/router/modules/document'
import brokerageRouter from '@/router/modules/brokerage'
import productRouter from '@/router/modules/product'
import analysisRouter from '@/router/modules/analysis'
import advertisementRouter from '@/router/modules/advertisement'
import supplierRouter from '@/router/modules/supplier'
import schoolRouter from '@/router/modules/school.js'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    forget: true,
    hidden: true
  },

  {
    path: '/viewData/*',
    component: () => import('@/views/analysis/viewData'),
  },


  {
    path: '/404',
    component: () => import('@/views/404'),
    forget: true,
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/index',
    forget: true,
    hidden: true,
    children: [{
      path: 'index',
      name: 'index',
      component: () => import('@/views/index/index'),
      meta: { title: '首页', icon: 'index' }
    }]
  },

  // orderRouter,
  commodityRouter,
  userRouter,
  documentRouter,
  productRouter,
  brokerageRouter,
  analysisRouter,
  globalRouter,
  advertisementRouter,
  supplierRouter,
  schoolRouter,


  // purchasingRouter,
  // warehouseRouter,
  // sortingRouter,
  // marketingRouter,
  // financialRouter,
  // kitchenRouter,
  // distributionRouter,

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', forget: true, hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  window.location.reload()
  router.matcher = newRouter.matcher
}

export default router
